﻿@using XStudio.WebFramework.Mvc.Extensions
<script type="text/javascript">
    var GoodsList = {};

    //表格显示修改按钮
    GoodsList.EditFormatter = function (value, rec, index) {
        return "<a  class='btn-edit' href='" + $("#fameditUrl").val() + "/" + rec.UID + "' onclick='GoodsList.Edit(this); return false;' >修改</a>";
    }

    //修改按钮触发方法
    GoodsList.Edit = function (e) {
        var title = "修改" + $(e).parents("tr").find("td:first").text();
        $.createWin({ url: e.href, width: 550, height: 420, title: title });
    }
    //表格显示删除按钮
    GoodsList.ApplyFormatter = function (value, rec, index) {
        return "<a  class='btn-manage' href='" + $("#applyUrl").val() + "/?id=" + rec.UID + "&Type=1" + "' onclick='GoodsList.Apply(this); return false;' >删除</a>";
    }

    //删除按钮触发事件
    GoodsList.Apply = function (e) {
        if (!confirm("确认通过审核吗？"))
            return;
        $.post($(e).attr("href"), function (data) {
            if (data.IsOK) {
                $("#tbGoodsList" + '@ViewBag.Type').datagrid('reload');
                $("#tbGoodsList1").datagrid('reload');
            }
            else
                alert(data.Description);
        });
    }

    //表格显示删除按钮
    GoodsList.ApplyFalseFormatter = function (value, rec, index) {
        return "<a  class='btn-manage' href='" + $("#applyUrl").val() + "/?id=" + rec.UID + "&Type=2" + "' onclick='GoodsList.ApplyFalse(this); return false;' >删除</a>";
    }

    //删除按钮触发事件
    GoodsList.ApplyFalse = function (e) {
        if (!confirm("确认审核失败吗？"))
            return;
        $.post($(e).attr("href"), function (data) {
            if (data.IsOK) {
                $("#tbGoodsList" + '@ViewBag.Type').datagrid('reload');
                $("#tbGoodsList2").datagrid('reload');
            }
            else
                alert(data.Description);
        });
    }

    //表格显示删除按钮
    GoodsList.NameFormatter = function (value, rec, index) {
        return rec.TypeName + " - " + rec.ProductName;
    }

    //是否执行ready函数标记
    GoodsList.Binded = false;

    $(document).ready(function () {
        if (GoodsList.Binded) return;
        GoodsList.Binded = true;
        //按钮搜索事件
        $("#btnIMEIInfoSearch").unbind("click");
        $("#btnIMEIInfoSearch").click(function () {
            $("#tbGoodsList").datagrid({ pageNumber: 1, queryParams: { SearchWord: $("#txtIMEIInfoSearchWord").val() } });
        });

        //呈现列表数据
        $("#tbGoodsList" + '@ViewBag.Type').datagrid({ pagination: true });
    });

</script>
@Html.Hidden("applyUrl", Url.Action("Apply"))
<div class="tt-attach">
    <ul class="op">
        <li>
            <input class="search-text" id="txtIMEIInfoSearchWord" style="width: 150px;" type="text" title="请输入IMEI进行搜索" value="" /><input id="btnIMEIInfoSearch" class="search-button" value="搜索" type="button" />
        </li>
    </ul>
</div>
<div style="padding: 5px 10px;">
    <table id=@("tbGoodsList" + ViewBag.Type) style="height:auto" stridep="true" rownumbers="true" fitColumns="true" title="" iconcls="icon-edit" fix="true"
           idfield="UID" pagesize="30" url="@Url.Action("ListData", new { Type = ViewBag.Type })">
        <thead>
            <tr>
                <th field="UID" checkbox="true" width="150">
                </th>
                <th field="ProductionGoodsName"  width="80" align="center">
                    生资商
                </th>
                <th field="ProductName" formatter="GoodsList.NameFormatter" width="80" align="center">
                    生资类型
                </th>
                <th field="Name" width="80" align="center">
                    产品名称
                </th>
                <th field="Specifications" width="80" align="center">
                    规格
                </th>
                <th field="Manufactor" width="80" align="center">
                    产家
                </th>
                <th field="ManufactureDate" formatter="Common.DateFormatter" width="80" align="center">
                    生产日期
                </th>
                <th field="Price" width="80" align="center">
                    价格
                </th>
                <th field="Unit" width="80" align="center">
                    单位
                </th>
                @if (ViewBag.Type == 0)
                {
                    <th field="通过审核" width="50" formatter="GoodsList.ApplyFormatter" align="center">
                        通过审核
                    </th>
                    <th field="审核拒绝" width="50" formatter="GoodsList.ApplyFalseFormatter" align="center">
                        审核拒绝
                    </th>
                }
        </thead>
    </table>
</div>
